package com.t2t.top.controller;

import com.t2t.top.framework.base.BaseController;
import com.t2t.top.framework.log.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/log")
public class LogController extends BaseController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @RequestMapping("/changeLevel")
    public String changeLevel(@RequestParam("name") String name, @RequestParam("level") String level) {
        logger.info("name:{},level:{}", name, level);
        LogUtils.changeLevel(name, level);
        return list();
    }

    @RequestMapping("/list")
    public String list() {
        this.getRequest().setAttribute("list", LogUtils.getLogs());
        this.getRequest().setAttribute("birth", LogUtils.getBirth());
        return "log/list";
    }


}  